<?php
require_once ("src/db/connectdatabase.php");

function getIntro($id) {
	$con = new ConnectDB();
	$tbl = "gioithieu";
	$fn = array('content');
	$condetion = array('id' => $id);
	return $con -> getvalue($tbl, $fn, $condetion);
}
$intro = getIntro('sosanhinfo');
$introfooter = getIntro('so_sanh_info_footer');
	?>
<style>
.class-content-search-loan-left {
	width: 150px;
	float: left;
	-moz-box-shadow: 5px 0px 5px #dddddd;
	-webkit-box-shadow: 5px 0px 5px #dddddd;
	box-shadow: 5px 0px 5px #dddddd;
	min-height: 400px;
	padding: 10px;
}

.class-content-search-loan-right {
	width: 800px;
	margin-left: 0px;
	float: left;
	padding-left: 10px;
}

.class-name-search-left {
	width: 140px;
	margin-right: 10px;
}

.class-inputtext-search-left {
	margin-right: 10px;
	width: 140px;
	height: 20px;
	padding: 5px;
}

.class-inputselect-search-left {
	margin-right: 10px;
	width: 152px;
	height: 30px;
	padding: 5px;
}

.class-records-search-line {
	margin-top: 20px;
}

.class-content-result-search, .class-menu-result-search, .class-result-line-search {
	width: 810px;
}

.class-menu-title {
	height: 50px;
	background: #8DAE48;
	color: #FFF;
	font-weight: bold;
	font-size: 13px;
	text-align:center;
	line-height: 50px;
}

.class-result-checkbox {
	width: 20px;
}

.class-result-rowend {
	width: 50px;
}

.class-menu-line {
	cursor: default;
	float: left;
	min-height: 50px;
	text-align: center;
}

.class-line-marrin {
	margin-top: 15px;
}

.class-line-bank {
	width: 90px;
}

.class-title-border-right {
	border-right: 1px solid;
}

.class-line-mucdichvay {
	width: 180px;
	/*overflow:hidden;40
word-wrap: break-word;*/
}

.class-line-amount {
	width: 120px;
	overflow: hidden;
word-wrap: break-word;
}

.class-line-time {
	width: 60px;
	overflow: hidden;
word-wrap: break-word;
}

.class-line-rate {
	width: 70px;
	overflow: hidden;
word-wrap: break-word;
}

.class-line-phiung {
	width: 120px;
	overflow: hidden;
word-wrap: break-word;
}

.class-line-month {
	width: 155px;
	overflow: hidden;
word-wrap: break-word;
}

.class-line {
	position: relative;
}

.color1 {
	background: #F1F1F1;
	overflow: hidden;
}
.class-checkbox {
	margin-top: 18px;
}

.box-shopcard {
	position: fixed;
	width: 200px;
	height: 100px;
	border: 1px solid;
	border-top-right-radius: 10px;
	-moz-box-shadow: 5px -5px 8px #dddddd;
	-webkit-box-shadow: 5px -5px 8px #dddddd;
	box-shadow: 5px -5px 8px #dddddd;
	bottom: 0px;
	left:0px;
	z-index: 30;
	background: #FFF;
}

/*.close-reveal-shopcard {
	font-size: 22px;
	line-height: .5;
	position: absolute;
	top: 8px;
	right: 11px;
	color: #000;
	text-shadow: 0 -1px 1px rbga(0,0,0,.6);
	font-weight: bold;
	cursor: pointer;
}*/

.box-shopcard-small {
	position: fixed;
	width: 200px;
	height: 30px;
	border: 1px solid;
	border-top-right-radius: 10px;
	-moz-box-shadow: 5px -5px 8px #dddddd;
	-webkit-box-shadow: 5px -5px 8px #dddddd;
	box-shadow: 5px -5px 8px #dddddd;
	bottom: 0px;
	left:0px;
	background: #CCC;
	cursor: pointer;
	display: none;
	z-index: 30;
}

.class-content-result-loading {
	position: fixed;
	height: 100%;
	width: 100%;
	background: #000;
	background: url(<?php echo($host) ?>images/ajax-load.gif) no-repeat center rgba(0,0,0,.8);
	background-size: 80px;
	z-index: 100;
	top: 0;
	left: 0;
	display: none;
}

#paging-loading {
    background: url(<?php echo($host) ?>images/paging_loading.gif) no-repeat center;
    height: 13px;
    margin: auto;
    width: 100%;
	bottom: 5px;
	clear: both;
	display: none;
}

.class-div-fly {
    position: absolute;
    left: 50%;
    top: 50%;
    background-color: #f1f1f1;
    z-index: 100;
    height: 100px;
    margin-top: -50px;
    min-width: 100px;
    margin-left: -50px;
	border-top-right-radius: 10px;
	-moz-box-shadow: 4px -5px 8px #dddddd;
	-webkit-box-shadow: 4px -5px 8px #dddddd;
	box-shadow: 4px -5px 8px #dddddd;
}
</style>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(document).ready(function(e) {
    //$('#slider').slider({ min: 0, max: 5000000000 });
	//$("#slider").slider( "option", "step", 100000000 );
	
	$('#slider').slider({
		range: "min",
		value: 50000000,
		min: 0,
		step: 10000000,
		max:  500000000,
		slide: function( event, ui ) {
			$( "#form_search_amount" ).val( "" + ui.value );
		}
	});
	
	$('#slider-time-loan').slider({
		range: "min",
		value: 2,
		min: 0,
		step: 0.5,
		max:  10,
		slide: function( event, ui ) {
			$( "#form_search_time" ).val( "" + ui.value );
		}
	});
	
	$('#slider-salarypermonth').slider({
		range: "min",
		value: 2,
		min: 1,
		step: 1,
		max:  10,
		slide: function( event, ui ) {
			$( "#form_search_salarypermonth" ).val( "" + ui.value );
		}
	});
});
</script>
<div class="text12" style="margin: auto; width: 970px; height: 11px; margin-top: 11px; color: #0a8bd9;">
	<u><a href="<?php echo($host) ?>" class="text12" style="color: #0080d6;">Trang Chủ</a></u>&gt; <a href="#" class="text12" style="color: #4c4c4c;">Tìm kiếm khoản vay tín chấp tốt chấp</a>
</div>
<div style="clear: both; height: 5px;"></div>
<div class="intrl_txt">
    <?php 
	if(count($intro) == 1) {
	?>
    <div class="text11" style="color: #4c4c4c; width: 950px; margin-left: 8px; margin-top: 10px;"><?php echo($intro[0][0]) ?></div>
    <?php
	}
	?>
</div>
<div style="clear:both; height: 15px;"></div>
<div style="clear: both; margin-bottom: 15px; margin-left: 15px;"><span> Cập nhật cuối cùng ngày: <?php echo date("d/m/Y",time()); ?></span></div>
<div class="class-content-result-loading"></div>
<div style="width:980px; margin: auto;">
	<div class="class-content-search-loan-left">
    	<div>
        	<span class="class-name-search-left">Nhu cầu vay(đồng)</span>
            <input class="class-inputselect-search-left" id="form_search_amount" placeholder="" value="50000000" maxlength="30" type="text" />
            <div id="slider" style="width:152px; margin-top: 10px;"></div>
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Thời hạn vay(năm)</span>
            <input class="class-inputselect-search-left" id="form_search_time" placeholder="" value="2" maxlength="6" type="text" />
            <div id="slider-time-loan" style="width:152px; margin-top: 10px;"></div>
            
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Thu nhập của bạn (triệu đồng/tháng)</span>
            <input class="class-inputselect-search-left" id="form_search_salarypermonth" placeholder="" value="2" maxlength="6" type="text" />
            <div id="slider-salarypermonth" style="width:152px; margin-top: 10px;"></div>
            
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Khoảng vay tối đa</span>
            <select class="class-inputselect-search-left class-khoanvaytoida-search" id="form_search_khoanvaytoida" onchange="loaddatasearch()"><option value="">-- Tất Cả --</option><option value="1">Dưới 6 lần thu nhập</option><option value="2">Trên 6 lần thu nhập</option></select>
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Hình thức trả lương</span>
            <select class="class-inputselect-search-left class-hinhthuctraluong-search" id="form_search_hinhthuctraluong" onchange="loaddatasearch()"><option value="">-- Tất Cả --</option><option value="1">Tiền mặt</option><option value="2">Chuyển khoản</option></select>
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Khu vực cho vay</span>
            <select id="ProvinceID" name="From_Province"  class="class-inputselect-search-left class-mucdichvay-search" onchange="loaddatasearch()">
                            <option selected="selected" value="">Toàn quốc</option>
                            <option value="Hà Nội">Hà Nội</option><option value="Hồ Chí Minh">TP HCM</option><option value="Cần Thơ">TP Cần Thơ</option><option value="Đà Nẵng">TP Đà Nẵng</option><option value="Hải Phòng">TP Hải Phòng</option><option value="An Giang">An Giang</option><option value="Vũng Tàu">Bà Rịa - Vũng Tàu</option><option value="Bắc Giang">Bắc Giang</option><option value="Bắc Kạn">Bắc Kạn</option><option value="Bạc Liêu">Bạc Liêu</option><option value="Bắc Ninh">Bắc Ninh</option><option value="Bến Tre">Bến Tre</option><option value="Bình Định">Bình Định</option><option value="Bình Dương">Bình Dương</option><option value="Bình Phước">Bình Phước</option><option value="Bình Thuận">Bình Thuận</option><option value="Cà Mau">Cà Mau</option><option value="Cao Bằng">Cao Bằng</option><option value="Đăk Lăk">Đăk Lăk</option><option value="Đak Nông">Đak Nông</option><option value="Điện Biên">Điện Biên</option><option value="Đồng Nai">Đồng Nai</option><option value="Đồng Tháp">Đồng Tháp</option><option value="Gia Lai">Gia Lai</option><option value="Hà Giang">Hà Giang</option><option value="Hà Nam">Hà Nam</option><option value="Hà Tĩnh">Hà Tĩnh</option><option value="Hải Dương">Hải Dương</option><option value="Hậu Giang">Hậu Giang</option><option value="Hòa Bình">Hòa Bình</option><option value="Hưng Yên">Hưng Yên</option><option value="Khánh Hòa">Khánh Hòa</option><option value="Kiên Giang">Kiên Giang</option><option value="Kon Tum">Kon Tum</option><option value="Lai Châu">Lai Châu</option><option value="Lâm Đồng">Lâm Đồng</option><option value="Lạng Sơn">Lạng Sơn</option><option value="Lào Cai">Lào Cai</option><option value="Long An">Long An</option><option value="Nam Định">Nam Định</option><option value="Nghệ An">Nghệ An</option><option value="Ninh Bình">Ninh Bình</option><option value="Ninh Thuận">Ninh Thuận</option><option value="Phú Thọ">Phú Thọ</option><option value="Phú Yên">Phú Yên</option><option value="Quảng Bình">Quảng Bình</option><option value="Quảng Nam">Quảng Nam</option><option value="Quảng Ngãi">Quảng Ngãi</option><option value="Quảng Ninh">Quảng Ninh</option><option value="Quảng Trị">Quảng Trị</option><option value="Sóc Trăng">Sóc Trăng</option><option value="Sơn La">Sơn La</option><option value="Tây Ninh">Tây Ninh</option><option value="Thái Bình">Thái Bình</option><option value="Thái Nguyên">Thái Nguyên</option><option value="Thanh Hóa">Thanh Hóa</option><option value="Thừa Thiên Huế">Thừa Thiên Huế</option><option value="Tiền Giang">Tiền Giang</option><option value="Trà Vinh">Trà Vinh</option><option value="Tuyên Quang">Tuyên Quang</option><option value="Vĩnh Long">Vĩnh Long</option><option value="Vĩnh Phúc">Vĩnh Phúc</option><option value="Yên Bái">Yên Bái</option>  
                        </select>
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Lãi suất</span>
            <select class="class-inputselect-search-left class-mucdichvay-search" id="form_search_rate" onchange="loaddatasearch();"><option value="">-- Tất Cả --</option><option value="1">Lãi suất dư nợ giảm dần</option><option value="2">Lãi suất dư nợ ban đầu</option></select>
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Tất toán trước hạn</span>
            <select class="class-inputselect-search-left class-mucdichvay-search" id="form_search_tattoantrchan" onchange="loaddatasearch();"><option value="">-- Tất Cả --</option><option value="cophi">Có Phí</option><option value="khongphi">Không Phí</option></select>
        </div>
        <div class="class-records-search-line">
        	<span class="class-name-search-left">Tổ chức cho vay</span>
            <select class="class-inputselect-search-left class-mucdichvay-search" id="form_search_bank" onchange="loaddatasearch();"><option value="">-- Tất Cả --</option><option value="bank">Ngân Hàng</option><option value="phibank">Công Ty Tài Chính</option></select>
        </div>
    </div>
    <div class="class-content-search-loan-right">
    	<div class="class-content-result-search" style="border: 1px solid; overflow: hidden; border-top-left-radius: 5px; border-top-right-radius: 5px;">
        	<div class="class-menu-result-search">
            	<div class="class-result-checkbox class-menu-title class-menu-line" style="border-top-left-radius: 5px;"></div>
                <div class="class-line-bank class-menu-title class-menu-line class-title-border-right" style="cursor: pointer;">Tổ chức</div>
                <div class="class-line-mucdichvay class-menu-title class-menu-line class-title-border-right" style="cursor: pointer;">Điều kiện căn bản</div>
                <div class="class-line-amount class-menu-title class-menu-line class-title-border-right" style="cursor: pointer;">Khoản vay tối đa</div>
                <div class="class-line-rate class-menu-title class-menu-line class-title-border-right" style="cursor: pointer;">Lãi suất</div>
                <div class="class-line-phiung class-menu-title class-menu-line class-title-border-right" style="cursor: pointer;">Tất toán trước hạn</div>
                <div class="class-line-month class-menu-title class-menu-line" style="cursor: pointer;">Thanh toán hàng tháng</div>
                <div class="class-result-rowend class-menu-title class-menu-line" style="border-top-right-radius: 5px;"></div>
            </div>
            <div class="class-content-insert-result-line"></div>
        </div>
    </div>
</div>
<div style="clear: both; height: 15px;"></div>
<div class="intrl_txt">
    <?php 
	if(count($introfooter) == 1) {
	?>
    <div class="text11" style="color: #4c4c4c; width: 950px; margin-left: 8px; margin-top: 10px;"><?php echo($introfooter[0][0]) ?></div>
    <?php
	}
	?>
</div>
<div style="clear:both;"></div>
<div class="box-shopcard">
	<div style="height: 30px; background:#8DAE48; margin-top:-5px; border-top-right-radius: 10px; cursor: pointer;" class="close-reveal-shopcard">
    	<h3 style="margin-top: 5px; margin-left: 30px; color: #FFF">Có <span style="color:#F00;" class="box-shopcard-countsp">0</span> SP So Sánh</h3>
    </div>
    <div">
    	<input type="button" style="margin-top: 5px; cursor: pointer; width: 200px; height:40px; text-align: center; border: 0px; font-size: 16px; font-weight:bold; font-family: Tahoma, Geneva, sans-serif; background: #bfd255; background: -moz-linear-gradient(top, #bfd255 0%, #8eb92a 50%, #72aa00 51%, #9ecb2d 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bfd255), color-stop(50%,#8eb92a), color-stop(51%,#72aa00), color-stop(100%,#9ecb2d)); background: -webkit-linear-gradient(top, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); background: -o-linear-gradient(top, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); background: -ms-linear-gradient(top, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); background: linear-gradient(to bottom, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bfd255', endColorstr='#9ecb2d',GradientType=0 );" value="So Sánh" class="box-shopcard-button-submit" />
        <span style="color:#690; font-size:12px; padding-left: 30px;">So sánh tối đa 4 danh mục</span>
    </div>
	<!--<a class="close-reveal-shopcard">&#215;</a>-->
</div>
<div class="box-shopcard-small"><h3 style="margin-top: 5px; margin-left: 30px; color: #FFF;">Có <span style="color:#F00;" class="box-shopcard-countsp">0</span> SP So Sánh</h3></div>
<div id="paging-loading" style=""></div>

<!-- <input type="button" style="margin-top: 20px; cursor: pointer; width: 45px; height:15px; text-align: center; border: 0px; font-size: 7px; font-weight:bold; background: #bfd255; background: -moz-linear-gradient(top, #bfd255 0%, #8eb92a 50%, #72aa00 51%, #9ecb2d 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#bfd255), color-stop(50%,#8eb92a), color-stop(51%,#72aa00), color-stop(100%,#9ecb2d)); background: -webkit-linear-gradient(top, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); background: -o-linear-gradient(top, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); background: -ms-linear-gradient(top, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); background: linear-gradient(to bottom, #bfd255 0%,#8eb92a 50%,#72aa00 51%,#9ecb2d 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=#bfd255, endColorstr=#9ecb2d,GradientType=0 ); border-radius:5px;" value="Đăng Ký"/></a> -->
<script>
$(document).ready(function(e) {
	var arridprocheck = new Array();
	// load first
	$('.box-shopcard-countsp').html(countidprocheck() + "/4");
	//dragbackgroundresult();
	
	// mo lai nhé
	loaddata();
	
	// drag backgroud
	function dragbackgroundresult() {
		var i = 1;
		$('.class-result-line-search').each(function() {
			if(i == 0) {
				$(this).addClass('color1');
				i = 1;
			} else {
				i = 0;
			}
		});
	}
	
	$('.class-checkbox').each(function() {
		var value = $(this).attr('value');
		if(checkexitsarridpro(value)) {
			$(this).attr("checked", "checked");
		} else {
			$(this).attr("checked", false);
		}
	});
	//-----------------------------------
	function countidprocheck() {
		return arridprocheck.length;
	}
	
	//key press search textbox
	$(document).on("keypress", "#form_search_amount", function(ev) {
		
		var keycode = (ev.keyCode ? ev.keyCode : ev.which);
		if (keycode == 13) {
			var amount = $.trim($('#form_search_amount').val());
			var re_num = /^([^0-9]*)$/;
			if(amount.length > 0) {
				if(re_num.test(amount)) {
					alert("Bạn phải nhập là số");
					$('#form_search_amount').val("");
					return false;
				}
			}
			// load data
			loaddata();
		}
	});
	
	//key press search textbox
	$(document).on("keypress", "#form_search_time", function(ev) {
		
		var keycode = (ev.keyCode ? ev.keyCode : ev.which);
		if (keycode == 13) {
			var amount = $.trim($('#form_search_time').val());
			if(amount.length > 0) {
				// load data
				loaddata();
			} else {
				$('#form_search_time').val("");
				return false;
			}
		}
	});
	
	//key press search textbox
	$(document).on("keypress", "#form_search_salarypermonth", function(ev) {
		
		var keycode = (ev.keyCode ? ev.keyCode : ev.which);
		if (keycode == 13) {
			var amount = $.trim($('#form_search_salarypermonth').val());
			if(amount.length > 0) {
				// load data
				loaddata();
			} else {
				$('#form_search_salarypermonth').val("");
				return false;
			}
		}
	});
	
	$( "#slider" ).slider({
		change: function( event, ui ) {
			var amount = $( "#slider" ).slider( "value" );
			$('#form_search_amount').val(amount);
			// load data
			loaddata();
		}
	});
	
	$( "#slider-time-loan" ).slider({
		change: function( event, ui ) {
			var amount = $( "#slider-time-loan" ).slider( "value" );
			$('#form_search_time').val(amount);
			// load data
			loaddata();
		}
	});
	
	$( "#slider-salarypermonth" ).slider({
		change: function( event, ui ) {
			var amount = $( "#slider-salarypermonth" ).slider( "value" );
			$('#form_search_salarypermonth').val(amount);
			// load data
			loaddata();
		}
	});
	
	loaddatasearch = function() {
		loaddata();
	}
	
	function loaddata() {
		var amount = $.trim($('#form_search_amount').val());
		if(amount == "") {
			amount = 0;
			$('#form_search_amount').val('0');
		}
		var re_num = /^([^0-9]*)$/;
		if(amount.length > 0) {
			if(re_num.test(amount)) {
				$('#form_search_amount').val("");
				amount = 0;
			}
		}
		var time = $('#form_search_time').val();
		if(time == 0) {
			time = "";
		}
		
		var thunhapcuaban = $('#form_search_salarypermonth').val();
		if(thunhapcuaban == 0) {
			thunhapcuaban = "";
		}
		
		var khoanvaytoida = $('#form_search_khoanvaytoida').val();
		var hinhthuctraluong = $('#form_search_hinhthuctraluong').val();
		var bank = $('#form_search_bank').val();
		var contr = $('#ProvinceID').val();
		var trate = $('#form_search_rate').val();
		var trchan = $('#form_search_tattoantrchan').val();
		
		$('.class-content-result-loading').show();
		
		
		$('.class-content-insert-result-line').html('');
		$.ajax({
			type: "POST",
			url: "<?php echo($host) ?>control/ajaxcomparerate.php",
			data:{act: 'load', 'amounre': amount, 'start': time, 'salary': thunhapcuaban, 'ratemax': khoanvaytoida, 'typepaysalary': hinhthuctraluong, 'bankre': bank, 'contry': contr, 'tyrate': trate, 'ttrchan': trchan},
			dataType: "json",
			success: function(response){
				if(response != "null") {
					if(amount != 0) {
						for(i = 0; i < response.length; i++) {
							draginsertrow(response[i][0], response[i][1], response[i][2], response[i][3], response[i][4], amount,response[i][6], response[i][7], response[i][8], response[i][9], response[i][10]);
						}
					} else if (amount == 0) {
						for(i = 0; i < response.length; i++) {
							draginsertrow(response[i][0], response[i][1], response[i][2], response[i][3], response[i][4], response[i][5], response[i][6], response[i][7], response[i][8], response[i][9], response[i][10]);
						}
					}
					
					arridprocheck = new Array();
					$('.box-shopcard-countsp').html(countidprocheck() + "/4");
					dragbackgroundresult();
				} else {
					$('.class-content-insert-result-line').html('<div class="class-result-line-search" style="background:#F1F1F1; text-align: center;">Không Tìm Thấy Dữ Liệu</div>');
				}
				setTimeout(function() { $('.class-content-result-loading').hide(); }, 500);
			}
		});
	}
	
	function draginsertrow(id, bank, bankname, banklogo, khoanvaytoida, amountmin, amountmax, rate, rate2, tattoan, dieukien) {
		amountmonth = Math.round((amountmin * rate) / 100 / 12);
		amountmonth2 = Math.round((amountmax * rate2) / 100 / 12);
		var html = '<div style="clear:both;"></div>';
            html +='<div class="class-result-line-search">';
            html +='<div class="class-result-checkbox class-menu-line"><span class="class-line"><input type="checkbox" class="class-checkbox" value="' + id + '" /></span></div>';
            html +='<div class="class-line-bank class-menu-line"><span class="class-line"><img title="' + bankname + '(' + bank + ')" src="<?php echo($host) ?>' + banklogo + '" width="80px" style="margin-top:5px; margin-bottom:5px;" /></span></div>';
            html +='<div class="class-line-mucdichvay class-menu-line class-line-marrin"><span class="class-line"><div style="margin-top: -13px;">' + dieukien + '</div></span></div>';
            html +='<div class="class-line-amount class-menu-line class-line-marrin"><span class="class-line">' + khoanvaytoida + '</span></div>';
            html +='<div class="class-line-rate class-menu-line class-line-marrin"><span class="class-line">' + rate + '%/năm<br>-<br>' + rate2 + '%/năm</span></div>';
            html +='<div class="class-line-phiung class-menu-line class-line-marrin"><span class="class-line">' + tattoan + '</span></div>';
            html +='<div class="class-line-month class-menu-line" style="margin-top: 10px;"><span class="class-line">' + partnumbertomoney(amountmonth) + ' VNĐ<br/>-<br/>' + partnumbertomoney(amountmonth2) + ' VNĐ</span></div>';
            html +='<div class="class-result-rowend class-menu-line"><a style="text-decoration: none;" target="_bank" href="<?php echo($host) ?>vay-tin-chap/ap-dung-cho-vay-ca-nhan/bank/' + bank + '.html"><img style="margin-top: 10px; cursor: pointer;" src="<?php echo($host) ?>images/dangky.png" width="50px" height="20" /></a> <a style="text-decoration: none;" target="_bank" href="<?php echo($host) ?>so-sanh-vay/chi-tiet/' + id + '.html"><img style="margin-top: 10px; cursor: pointer;" src="<?php echo($host) ?>images/icon_chitiet.gif" width="50px" height="15" /></a></div>';
            html +='</div>';
		$('.class-content-insert-result-line').append(html).children(".class-result-line-search:last").hide().fadeIn(200);
	}
	
    $(document).on('click', '.class-checkbox', function() {
		elem = $(this);
		value = elem.attr('value');
		logobank = elem.parent().parent().siblings('.class-line-bank').children().find('img').attr('src');
		
		if(elem.is(':checked')) {
			if(countidprocheck() < 4) {//sscom
				$('.class-content-result-loading').show();
				$.ajax({
					type: "POST",
					url: "<?php echo($host) ?>control/ajaxcomparerate.php",
					data:{act: 'sscom', pr: 'add', idre: value},
					dataType: "json",
					success: function(response){
						if(response == "ok") {
							arridprocheck.push(value);
							$('.box-shopcard-countsp').html(countidprocheck() + "/4");
							$('body').append('<div class="class-div-fly"><img src="'+logobank+'" height="80px" style="margin: 10px;" /></div>');
							$('.class-div-fly').fadeIn(200, function() { $('.class-div-fly').show(); clickfly();});
						} else {
							elem.attr("checked", false);
						}
						$('.class-content-result-loading').hide();
					}
				});
			} else {
				elem.attr("checked", false);
				alert("Bạn chỉ được phép so sánh nhiều nhất là 4 mục");
			}
		} else {
			$('.class-content-result-loading').show();
			$.ajax({
				type: "POST",
				url: "<?php echo($host) ?>control/ajaxcomparerate.php",
				data:{act: 'sscom', pr: 'del', idre: value},
				dataType: "json",
				success: function(response){
					if(response == "ok") {
						arridprocheck.splice($.inArray(value, arridprocheck),1);
						$('.box-shopcard-countsp').html(countidprocheck() + "/4");
					} else {
						elem.attr("checked", "checked");
					}
					$('.class-content-result-loading').hide();
				}
			});
		}
	});
	
	function clickfly() {
		var height = 400;
		var width = ($(window).width()/2) - $('.class-div-fly').width();
		$('.class-div-fly').animate({"top" : "+="+height+"px", "left" : "-="+width+"px"}, 1000, function() {
			$('.class-div-fly').fadeOut(300, function(){$('.class-div-fly').remove(); });
		});
	}
	
	function checkexitsarridpro(id) {
		for(var i in arridprocheck) {
			if(arridprocheck[i] == id) {
				return true;
			}
		}
		return false;
	};
	
	function partnumbertomoney(number) {
		number = (number + "");
		first = true;
		stemp = "";
		for(;;) {
			if(number.length > 3) {
				ext = number.substr(number.length-3, number.length);
				number = number.substr(0, number.length-3);
				if(!first) {
					stemp = ext + "." + stemp;
				} else {
					first = false;
					stemp = ext;
				}
			} else {
				stemp = number + "." + stemp;
				break;
			}
		}
		return stemp;
	}
	
	$(document).on('click', '.box-shopcard-small', function() {
		$(this).fadeOut(0, function() {
			$(this).hide();
			$('.box-shopcard').fadeIn(500, function() {
				$('.box-shopcard').show();
			});
		});
	});
	
	$(document).on('click', '.close-reveal-shopcard', function() {
		$('.box-shopcard').fadeOut(200, function() {
			$('.box-shopcard').hide();
			$('.box-shopcard-small').show();
		});
	});
	
	$(document).on('click', '.box-shopcard-button-submit', function() {
		if(countidprocheck() == 0) {
			alert("Vui lòng chọn danh mục cần so sánh \nBằng cách tích các ô đầu dòng mà bạn muốn so sánh");
		} else if(countidprocheck() <= 4) {
			window.location = "index.php?cont=san-pham-so-sanh";
		}
	});
	
});
</script>
